package kitrobot.com.bed.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.Toast;

import kitrobot.com.bed.Service.AddnextService;
import kitrobot.com.bed.Service.UpnextService;
import kitrobot.com.wechat_bottom_navigation.R;

public class AddpersonActivity extends AppCompatActivity implements View.OnClickListener {
    private String bid;
    private String token;
    private EditText et_apt;
    private EditText et_ast;
    private EditText et_aet;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.add_person);
        et_apt= (EditText) findViewById(R.id.et_apt);
        et_ast= (EditText) findViewById(R.id.et_ast);
        et_aet= (EditText) findViewById(R.id.et_aet);
        Intent intent = getIntent();
        bid =  intent.getStringExtra("bid");
        token =  intent.getStringExtra("token");
    }
    public void Addnext(View view){
        final String phone=et_apt.getText().toString().trim();
        final String starttime=et_ast.getText().toString().trim();
        final String endtime=et_aet.getText().toString().trim();
        new Thread() {
            public void run() {
                final String result = AddnextService.AddnextByClientPost(bid,phone,starttime,endtime, token);
                if (result != null) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            Toast.makeText(AddpersonActivity.this, result, Toast.LENGTH_LONG).show();
                        }
                    });
                } else {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(AddpersonActivity.this, "日期时间格式错误", Toast.LENGTH_LONG).show();
                        }
                    });
                }
            }



        }.start();
        finish();
    }
    public void Caidan1(View view){
        Intent intent=new Intent(this,MainActivity.class);
        intent.putExtra("flag",1);
        startActivity(intent);
    }
    public void Caidan2(View view){
        Intent intent=new Intent(this,MainActivity.class);
        intent.putExtra("flag",2);
        startActivity(intent);
    }
    public void Caidan3(View view){
        Intent intent=new Intent(this,MainActivity.class);
        intent.putExtra("flag",3);
        startActivity(intent);
    }
    public void Caidan5(View view){
        Intent intent=new Intent(this,MainActivity.class);
        intent.putExtra("flag",4);
        startActivity(intent);
    }
    public void Finish(View view){
        finish();
    }
    @Override
    public void onClick(View view) {

    }


}
